﻿using System.Collections.Generic;
using System.ServiceModel;
using System.Threading;
using System.Workflow.Activities;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Runtime.Hosting;
using System.Workflow.Runtime.Tracking;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Rhino.Mocks;
using YakShaver.Contract;
using YakShaver.YakServer;
using System.Reflection;
using System.Windows.Forms;
using System.Net.Mail;
namespace YakShaver.Tests
{
    public class UnitTestHelper
    {
        public static System.Net.Mail.SmtpClient GetSmtpClient(TestContext testContext)
        {
            SmtpClient smtpClient = new SmtpClient("localhost", 80);
            smtpClient.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
            smtpClient.PickupDirectoryLocation = testContext.TestLogsDir;
            return smtpClient;
        }

        public static void TestCleanup(ref ExternalDataExchangeService service)
        {
          
            
            
            try
            {
                INotificationService notificationService = (INotificationService)service.GetService(typeof(INotificationService));
                service.RemoveService(notificationService);
            }
            catch { }

            try
            {
                IAnalysisService analysisService = (IAnalysisService)service.GetService(typeof(IAnalysisService));
                service.RemoveService(analysisService);
            }
            catch { }

            try
            {
                IWorkItemProviderService providerService = (IWorkItemProviderService)service.GetService(typeof(IWorkItemProviderService));
                service.RemoveService(providerService);

            }
            catch { }
        }
    }
}
